import Base from '../../pages/base.js';
import UsersApi from '../../api/users.js';
export default class extends Base {
    async reg() {
        let username = this.usernameIpt.val();
        let password = this.passwordIpt.val();
        console.log(username, password);
        const data = await UsersApi.reg({
            username,
            password,
        });
        // console.log(data[0]);
            if (data[0]) {
                // this.tips.html(`账户名已存在`);
                alert(`账户名已存在`);
            } else {
                alert(`注册成功!`);
                location.hash="#/login";
            }
    }
    handle() {
        this.regBtn = $(".templateReg .reg-btn");
        this.usernameIpt = $("[name=username]");
        this.passwordIpt = $("[name=password]");
        this.tips = $('.templateReg .tips');
        this.regBtn.on("click", this.reg.bind(this));
        console.log(this.tips);
    }
}